package com.dylan.job.config;

import com.dylan.job.mapper.JobGroupMapper;
import com.dylan.job.mapper.JobInfoMapper;
import com.dylan.job.scheduler.JobScheduler;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Data
@Component
public class JobAdminConfig implements InitializingBean {

    private static JobAdminConfig adminConfig = null;

    public static JobAdminConfig getConfig() {
        return adminConfig;
    }


    @Resource
    private JobInfoMapper jobInfoMapper;

    @Resource
    private JobGroupMapper jobGroupMapper;

    @Override
    public void afterPropertiesSet() throws Exception {
        adminConfig = this;
        //初始化调度中心
        JobScheduler scheduler = new JobScheduler();
        scheduler.init();
    }
}